<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="./styles/reset.css">
  <title>两边定宽中间自适应</title>
  <!-- 初始化 -->
  <style>
    .container-root {
      width: 100%;
      background-color: azure;
      font-size: 20px;
      text-align: center;
    }

    header,
    footer {
      width: 100%;
      height: 30px;
      background-color: aqua;
    }

    .left {
      width: 100px;
      height: 150px;
      background: red;
    }

    .center {
      height: 100px;
      background: yellow;
    }

    .right {
      width: 100px;
      height: 130px;
      background: greenyellow;
    }
  </style>

  <style>
    /* 左中右 一行显示 */
    .left,
    .right,
    .container-center {
      float: left;
    }

    /* 创建BFC使底部换行 */
    footer {
      clear: both;
    }

    /* 中间区域宽度占满 
       给左右区域留出空间 */
    .container-center {
      width: 100%;
      height: 100px;
    }

    .center {
      margin: 0 100px;
    }

    /* 左区域移到指定位置 */
    .left {
      margin-left: -100%;
    }

    /* 右区域移到指定位置 */
    .right {
      margin-left: -100px;
    }
  </style>
</head>

<body>
  <div class="container-root">

    <header>头部</header>
    <div class="container-center">
      <div class="center">主区域</div>
    </div>
    <div class="left">左区域</div>
    <div class="right">右区域</div>

    <footer>底部</footer>

  </div>
</body>

</html>